Skip to content

Conversation

@morremeyer
Copy link
Contributor

what

This fixes the deprecation of the "name" attribute for the aws_region data source, adding a fallback for provider versions < 6.0.0.

why

To get rid of the deprecation notice and prepare for provider version 7.

references

Resolves #361.

This fixes the deprecation of the "name" attribute for the aws_region data source, adding a fallback for provider versions < 6.0.0.
@morremeyer morremeyer requested review from a team as code owners December 12, 2025 12:12
@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

Addressed AWS provider v6+ deprecation warning by introducing a fallback mechanism in main.tf that prioritizes the region attribute over the deprecated name attribute when accessing the current AWS region.

Changes

Cohort / File(s) Summary
Region Attribute Deprecation Fix
main.tf
Introduced new local variable aws_region_name using try() to safely fall back from region to name attribute. Updated origin_shield_region calculation to reference local.aws_region_name instead of directly accessing deprecated data.aws_region.current[0].name. Added compatibility comments for AWS provider v6 migration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify the try() fallback correctly prioritizes region over name for provider version compatibility
  • Confirm all references to the deprecated attribute have been migrated to use the new local variable
  • Validate that the fallback logic preserves intended behavior for both current and legacy AWS provider versions

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the deprecation warning for the aws_region data source 'name' attribute, which directly matches the changeset.
Description check ✅ Passed The description explains what was changed (fixing 'name' deprecation with fallback), why (prepare for provider v7), and references the related issue #361, all aligned with the changes.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #361 by adding a fallback mechanism using try() to handle the deprecated 'name' attribute in AWS provider v6+.
Out of Scope Changes check ✅ Passed All changes focus on fixing the aws_region data source deprecation warning, which is directly scoped to issue #361 requirements with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify mergify bot added the triage Needs triage label Dec 12, 2025
@goruha
Copy link
Member

goruha commented Jan 9, 2026

/terratest

@morremeyer
Copy link
Contributor Author

@goruha Looks like the terratest workflow is not running, can you re-trigger it?

@goruha
Copy link
Member

goruha commented Jan 12, 2026

/terratest

@goruha
Copy link
Member

goruha commented Jan 13, 2026

@morremeyer, tests are failing. Could you pls fix ?

│ Error: Error in function call
│ 
│   on ../../main.tf line 90, in locals:
│   90:   aws_region_name = try(data.aws_region.current[0].region, data.aws_region.current[0].name)
│     ├────────────────
│     │ while calling try(expressions...)
│     │ data.aws_region.current is empty tuple
│ 
│ Call to function "try" failed: no expression succeeded:
│ - Invalid index (at ../../main.tf:90,48-51)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ - Invalid index (at ../../main.tf:90,83-86)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ 
│ At least one expression must produce a successful result.
╵
╷
│ Error: Error in function call
│ 
│   on ../../main.tf line 90, in locals:
│   90:   aws_region_name = try(data.aws_region.current[0].region, data.aws_region.current[0].name)
│     ├────────────────
│     │ while calling try(expressions...)
│     │ data.aws_region.current is empty tuple
│ 
│ Call to function "try" failed: no expression succeeded:
│ - Invalid index (at ../../main.tf:90,48-51)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ - Invalid index (at ../../main.tf:90,83-86)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ 
│ At least one expression must produce a successful result.
╵
╷
│ Error: Error in function call
│ 
│   on ../../main.tf line 90, in locals:
│   90:   aws_region_name = try(data.aws_region.current[0].region, data.aws_region.current[0].name)
│     ├────────────────
│     │ while calling try(expressions...)
│     │ data.aws_region.current is empty tuple
│ 
│ Call to function "try" failed: no expression succeeded:
│ - Invalid index (at ../../main.tf:90,48-51)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ - Invalid index (at ../../main.tf:90,83-86)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ 
│ At least one expression must produce a successful result.
╵
╷
│ Error: Error in function call
│ 
│   on ../../main.tf line 90, in locals:
│   90:   aws_region_name = try(data.aws_region.current[0].region, data.aws_region.current[0].name)
│     ├────────────────
│     │ while calling try(expressions...)
│     │ data.aws_region.current is empty tuple
│ 
│ Call to function "try" failed: no expression succeeded:
│ - Invalid index (at ../../main.tf:90,48-51)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ - Invalid index (at ../../main.tf:90,83-86)
│   The given key does not identify an element in this collection value: the collection has no elements.
│ 
│ At least one expression must produce a successful result.
╵}

Copy link
Member

@goruha goruha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the comment ^

@morremeyer
Copy link
Contributor Author

morremeyer commented Jan 16, 2026

@goruha I fixed the errors, but noticed that the warning for the deprecated attribute does not go away, since it's still used in the code - the evaluation for that seems to be static.

So the way to fix this deprecation warning is to require provider versions >= 6.0, and only use the new attribute.
I verified this locally and pushed the change.

However, that makes this a breaking change, requring the Major label & corresponding version bump.

I see this as a viable solution, since the AWS provider version 6.0.0 was released in June 2025, allowing 7 months since then to update, and the assumption/requirement that someone updating this module also updated their AWS provider before (or will do so to update this module afterwards) is reasonable.

Happy to hear your thoughts!

@goruha
Copy link
Member

goruha commented Jan 16, 2026

/terratest

@goruha goruha added the major Breaking changes (or first stable release) label Jan 16, 2026
@goruha
Copy link
Member

goruha commented Jan 16, 2026

@morremeyer I think that's absolutely fine to cut a major version that requires provider >= 6.0.
LGTM

@goruha goruha merged commit 442e7c1 into cloudposse:main Jan 16, 2026
29 checks passed
@mergify mergify bot removed the triage Needs triage label Jan 16, 2026
@github-actions
Copy link
Contributor

These changes were released in v2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major Breaking changes (or first stable release)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws_region.current.name attribute is deprecated in version 6 of the AWS provider

2 participants